<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

	<h2 class="title"><a href="#">Consultar Pacotes</a></h2><br/>
	
    <h:form id="consultaPacotessForm">

			
	        <h:panelGrid columns="1">
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Cliente:</ui:define>
	        		<h:selectOneMenu value="#{consultarPacotesController.pacoteConsulta.cliente.idCliente}"
	        			rendered="#{usuarioLogado == null or usuarioLogado.cliente == null}">
	        			<f:selectItems value="#{consultarPacotesController.listaClientes}"/>
	        		</h:selectOneMenu>
	        		<h:inputText value="#{consultarPacotesController.pacoteConsulta.cliente.dscNome}" readonly="true"
	        			size="50"
	        			rendered="#{usuarioLogado != null and usuarioLogado.cliente != null}"/>
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Forma de pagamento:</ui:define>
	        		<h:selectOneMenu value="#{consultarPacotesController.pacoteConsulta.formaPagamento.idFormaPagamento}">
	        			<f:selectItems value="#{consultarPacotesController.listaFormasPagamento}"/>
	        		</h:selectOneMenu>
	        	</s:decorate>
	        
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Período:</ui:define>
	        		<rich:calendar value="#{consultarPacotesController.pacoteConsulta.dtaInicio}"
	        			datePattern="dd/MM/yyyy"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"/>
	        		à
	        		<rich:calendar value="#{consultarPacotesController.pacoteConsulta.dtaFim}"
	        			datePattern="dd/MM/yyyy"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"/>
	        	</s:decorate>
	        	
	        </h:panelGrid>
	        
	        <div class="actionButtons">
	            <h:commandButton id="pesq" value="Pesquisar" action="#{consultarPacotesController.pesquisar}"
	            	onclick="#{rich:component('carregando')}.show()"/>
	        </div>
	        
	        <center>
	        	<h1>RESULTADO</h1>
	        </center>
	        
	        	
	        	<rich:dataTable var="_result" value="#{consultarPacotesController.listaPacotes}"
	        		rows="10" id="tabelaPacotes">
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="CLIENTE"/></f:facet>
	        			<h:outputText value="#{_result.cliente.dscNome}"/>
	        			
	        			<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>Data de Início:</strong><h:outputText value="#{_result.dtaInicio}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Fim:</strong><h:outputText value="#{_result.dtaFim}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
						
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="DATA PAGAMENTO"/></f:facet>
	        			<h:outputText value="#{_result.dtaPagamento}">
	        				<s:convertDateTime pattern="dd/MM/yyyy"/>
	        			</h:outputText>
	        			
	        			<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>Data de Início:</strong><h:outputText value="#{_result.dtaInicio}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Fim:</strong><h:outputText value="#{_result.dtaFim}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="FORMA PAGAMENTO"/></f:facet>
	        			<h:outputText value="#{_result.formaPagamento.dscFormaPagamento}"
	        				rendered="#{_result.formaPagamento != null}"/>
	        				
	        			<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>Data de Início:</strong><h:outputText value="#{_result.dtaInicio}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Fim:</strong><h:outputText value="#{_result.dtaFim}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="VALOR"/></f:facet>
						<h:outputText value="#{_result.vlrPacote}" converter="conversorMonetario"/>
						
						<rich:toolTip followMouse="true" direction="top-right" showDelay="500"
							styleClass="tooltip" layout="block">
							<span style="white-space: nowrap">
								<table>
									<tr>
										<td>
											<strong>Data de Início:</strong><h:outputText value="#{_result.dtaInicio}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/>
											<strong>Data de Fim:</strong><h:outputText value="#{_result.dtaFim}"><s:convertDateTime pattern="dd/MM/yyyy"/></h:outputText><br/> 
										</td>
									</tr>
								</table> 
							</span>
						</rich:toolTip>
						
	        		</rich:column>
	        		
	        		<rich:column rendered="true">
		        		<f:facet name="header"></f:facet>
		        		<h:commandLink value="CONTRATO" target="blank"
		        			action="#{consultarPacotesController.gerarContrato(_result)}"/>
		        	</rich:column>
	        		
	        		<f:facet name="footer">
	        			<rich:columnGroup>
	        				<rich:column colspan="6">
		        				<h:outputText value="VALOR TOTAL: R$ " />
	        					<h:outputText value="#{consultarPacotesController.valorTotal}" converter="conversorMonetario"/>
	        				</rich:column>
	        			</rich:columnGroup>
	        		</f:facet>
	        	</rich:dataTable>
	        	<rich:datascroller for="tabelaPacotes"/>
	        	
	        	<h:commandButton action="#{excelExporter.export('consultaPacotessForm:tabelaPacotes')}"
	        		rendered="#{consultarPacotesController.listaPacotes.size() > 0}" 
	        		value="EXPORTAR EXCEL" />

    </h:form>

 </ui:define>
</ui:composition>
